<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
   <h:head>
   	<link rel="stylesheet" href="./resources/css/main.css" />
      <title>Create User</title>
   </h:head>
   <h:body>
      <div>
   	<ui:insert name="nav">
   	<ui:include src="nav.xhtml"/>
   	</ui:insert>
   </div>
   
   <div class="clear"></div>

<!-- Realname og username stammer fra fra http://www.primefaces.org/showcase/ui/commandButton.jsf  
Password fields stammer fra Stammer fra http://www.primefaces.org/showcase/ui/password.jsf-->    
   <h:form>
   <p:panel id="panel" styleClass="creatorPanel">  
        <h:panelGrid columns="3">  
            <h:outputLabel for="realname" value="Real name:" />  
            <p:inputText id="realname"   
                value="#{userBean.bufferUser.realName}" required="true" label="Realname"/>  
           	<p:message for="realname" /> 
              
            <h:outputLabel for="username" value="Username:" />  
            <p:inputText id="username"   
                value="#{userBean.bufferUser.userName}" required="true" label="Username"/>  
            <p:message for="username" />  

            <h:outputLabel for="pwd1" value="Password:" />  
            <p:password id="pwd1" value="#{userBean.bufferUser.password}" match="pwd2" label="Password 1" feedback="true" required="true"
            validatorMessage="Password must be at least 8 ciphers long, be upper and lower case and contain digits!">
							<f:validateRegex
								pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,30}$" />
			</p:password>
  			<p:message for="pwd1" />
  			
            <h:outputLabel for="pwd2" value="Reenter password:" />  
            <p:password id="pwd2" value="#{userBean.bufferUser.password}" label="Password 2" required="true"/>  
            <p:message for="pwd2" />  
        </h:panelGrid>  
    </p:panel> 

    
  
    <p:commandButton value="Create user"  action="#{userBean.createUser}" 
             ajax="false" />        
</h:form>  
   </h:body>
   </html>